package top.lunarye.support.delayMessage;

import org.apache.rocketmq.client.exception.MQClientException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author lunar
 * @since 2022-07-14
 */
@Configuration
public class DelayMessageProducerConfiguration {
    @Value("${rocket.delayGroup}")
    private String producerGroup;

    @Value("${rocket.url}")
    private String mqUrl;

    @Value("${rocket.retryTime}")
    private String retryTime;

    @Bean
    public DelayMessageProducer delayMessageProducer() throws MQClientException {
        DelayMessageProducer producer = new DelayMessageProducer();
        producer.initProducer(producerGroup, retryTime, mqUrl);
        producer.start();
        return producer;
    }
}
